package com.sdtv.basemodule.widget.gloading;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sdtv.basemodule.R;

/**
 * @ProjectName: MediunFusion
 * @Package: com.sdtv.basemodule.widget.gloading
 * @ClassName: GloadingEmptyView
 * @Description: 加载内容为空View
 * @Author: 小郭同学
 * @CreateDate: 2019-06-20 09:41
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class GloadingEmptyView extends LinearLayout {
    private TextView mTextView;
    private ImageView mImageView;
    private Runnable mRetryTask = null;

    public GloadingEmptyView(Context context) {
        super(context);
        initView(context);
    }

    public GloadingEmptyView(Context context, Runnable retryTask) {
        super(context);
        this.mRetryTask = retryTask;
        initView(context);
    }

    private void initView(Context context) {
        setOrientation(VERTICAL);
        setGravity(Gravity.CENTER_HORIZONTAL);
        LayoutInflater.from(context).inflate(R.layout.empty_view_layout, this, true);
        mImageView = findViewById(R.id.image);
        mTextView = findViewById(R.id.text);
        setBackgroundColor(0xFFF0F0F0);
    }

    public void setIvSrcResourecs(int srcResourecs) {
        if (mImageView != null) {
            mImageView.setImageResource(srcResourecs);
        }
    }

    public void setTvEmptyTip(String tipText) {
        if (mTextView != null) {
            mTextView.setText(tipText);
        }
    }
}
